//
//  MinimizeTabar.swift
//  onemeetingmac
//
//  Created by 张衡 on 2020/6/11.
//  Copyright © 2020 onemeeting. All rights reserved.
//

import Foundation

class MinimizeTabar: NSView {
    
    var uBtn:[ZHButton] = []
    var kWidth:CGFloat = 60
    var kHeight:CGFloat = 40
    var list:[String] = ["icon_mininal_toolbar_arraw_down_normal","icon_mininal_toolbar_mute_audio_normal","icon_mininal_toolbar_mute_video_normal","icon_mininal_toolbar_exit_normal",]
    
    override init(frame frameRect: NSRect) {
        super.init(frame: frameRect)
        self.setupUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setupUI() {
        self.uBtn = self.initTabar(inView: self)
        
    }
    
    func getWidth() -> CGFloat{
        return CGFloat(self.list.count)*kWidth
    }
    
    func initTabar(inView:NSView) -> [ZHButton] {
        var ubtn:[ZHButton] = []
        for (inx,val) in list.enumerated() {
            let btn = ZHButton()
            btn.normalImage = NSImage.image(name:val)!
            btn.zh_backgroundColor = NSColor.clear
            btn.backgroundHighlightColor = color_main108
            btn.backgroundHoverColor = color_gray(160)
            btn.backgroundSelectedColor = NSColor.clear
            inView.addSubview(btn)
            ubtn.append(btn)
            btn.snp.makeConstraints { (make) in
                make.width.equalTo(kWidth)
                make.height.equalTo(kHeight)
                make.centerY.equalToSuperview()
                if inx == 0 {
                    make.left.equalTo(0)
                }else {
                    make.left.equalTo(ubtn[inx-1].snp.right)
                }
                
            }
        }
        return ubtn
    }
}
